<template>
  <div>
    <a-input-search
      v-model="value"
      placeholder="请选择仓库"
      readOnly
      unselectable="on"
      @search="onSearchWarehouse">
      <a-button slot="enterButton">选择仓库</a-button>
    </a-input-search>

    <erp-warehouse-list-modal
      ref="warehouseListModal"
      :modal-width="modalWidth"
      @warehouseOk="selectOK"/>
  </div>
</template>
<script>
import ErpWarehouseListModal from "@comp/base/modal/ErpWarehouseListModal";

export default {
  components: {ErpWarehouseListModal},
  props: {
    modalWidth: {
      type: Number,
      default: 1250,
      required: false
    },    
    value: {
      type: String,
      default: "",
      required: false
    },
  },
  comments: {},
  data() {
    return {
      textVals: ''
    }
  },
  // watch:{
  //   value(newval){
  //   console.log("--------------warehouse----------------------")

  //   console.log(newval)
  //   this.textVals=newval
  //   this.$forceUpdate();
  //   console.log("--------------warehouse----------------------")

  //   console.log(this.textVals);
  //   }
  // },
  methods: {
    onSearchWarehouse() {
      this.$refs.warehouseListModal.showModal();
    },
    selectOK(rows) {
      this.textVals = "";
      if (rows) {
        this.textVals = rows.name;
        this.$emit("onWarehouseSelected", rows);
      }
    }
  }
}
</script>